package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 加班规则
 * </p>
 *
 * @author dqq
 * @date 2023-05-05
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "WorkOvertimeRuleOvertimeTypeEnum", description = "加班类型 #{SPACE_OVERTIME:整馆加班;SITE_OVERTIME:展位加班-枚举")
public enum WorkOvertimeRuleOvertimeTypeEnum implements BaseEnum {

    /**
     * SPACE_OVERTIME="整馆加班"
     */
    SPACE_OVERTIME("整馆加班"),
    /**
     * SITE_OVERTIME="展位加班"
     */
    SITE_OVERTIME("展位加班"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static WorkOvertimeRuleOvertimeTypeEnum match(String val, WorkOvertimeRuleOvertimeTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static WorkOvertimeRuleOvertimeTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(WorkOvertimeRuleOvertimeTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "SPACE_OVERTIME,SITE_OVERTIME", example = "SPACE_OVERTIME")
    public String getCode() {
        return this.name();
    }

}
